import type { ApiResponse, ListResponse } from '/@/types/api'
import request from '/@/utils/request'

// 定义StayInfo接口
export interface StayInfo {
  id: number
  activityId: string
  userId: string
  hotelManagementId: string
  houseType: string
  houseNumber: string
  dwellStartDate: string
  dwellEndDate: string
  remark: string
  createdAt?: string
  updatedAt?: string
  [key: string]: any
}

export interface ListParams {
  userId?: string
  hotelManagementId?: string
  houseType?: string
  dwellStartDate?: string
  dwellEndDate?: string
  activityId?: string
  page?: number
  limit?: number
}

// 获取列表
export const getListApi = (params: ListParams) => request.get<any, ApiResponse<ListResponse<StayInfo>>>('/api/hotelCheckin', { params })

// 获取详情
export const getDetailApi = (id: number) => request.get<any, ApiResponse<StayInfo>>(`/api/hotelCheckin/show/${id}`)

// 新增入住信息
export const addApi = (data: Partial<StayInfo>) => request.post<any, ApiResponse<StayInfo>>('/api/hotelCheckin', data)

// 更新入住信息
export const editApi = (data: Partial<StayInfo>) => request.put<any, ApiResponse<StayInfo>>(`/api/hotelCheckin/${data.id}`, data)

// 删除入住信息
export const delApi = (id: number) => request.delete<any, ApiResponse<void>>(`/api/hotelCheckin/${id}`)

// 下载模板
export const getTemplateApi = () => request.get<any, ApiResponse<string>>('/api/hotelCheckin/template')

// 批量导入
export const importApi = (data: FormData) =>
  request.post<any, ApiResponse<any>>('/api/hotelCheckin/import', data, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
